<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
    <head>
        <th:block th:include="include :: header('编辑用户')" />
        <script type="text/javascript">

            function submitHandler() {
                if ($.validate.form()) {
                    edit();
                }
            }

            function edit() {
                $("input[id='state']").val($("input[id='state']").is(':checked')==true ? 1 : 0);
                $("input[id='isValid']").val($("input[id='isValid']").is(':checked')==true ? 1 : 0);
                $.ajax({
                    cache : true,
                    type : "POST",
                    url : ctx + "admin/user/save",
                    data : $("#form-user-edit").serialize(),
                    async : false,
                    error : function(request) {
                        $.modal.alertError("系统错误");
                    },
                    success : function(data) {
                        $.operate.successCallback(data);
                    }
                });
            }
        </script>
    </head>
    <body class="white-bg">
        <div class="wrapper wrapper-content animated fadeInRight ibox-content">
            <form class="form-horizontal m" id="form-user-edit" th:object="${user}">
                <input type="hidden" name="userId" th:field="*{userId}" />
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户名称：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="abbrName" id="abbrName" th:field="*{abbrName}" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户职务：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="objName" id="objName" th:field="*{objName}" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户别称：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="aliasName" id="aliasName" th:field="*{aliasName}" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">内网邮箱：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="useremail" id="useremail" th:field="*{useremail}" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">上级单位：</label>
                    <div class="col-sm-8">
                        <input class="form-control" readonly type="text" name="superId" id="superId" th:field="*{superId}" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户状态：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input type="checkbox" id="state" name="state" th:checked="*{state==1}" checked>
                            <span></span>
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">是否显示：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input type="checkbox" id="isValid" name="isValid" th:checked="*{isValid==1}" checked>
                            <span></span>
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户级别：</label>
                    <div class="col-sm-8">
                        <select name="rankId" class="form-control m-b">
                            <option value="0" th:selected="*{rankId==0}">部级</option>
                            <option value="1" th:selected="*{rankId==1}">司级</option>
                            <option value="2" th:selected="*{rankId==2}">处级</option>
                            <option value="3" th:selected="*{rankId==3}">科级</option>
                            <option value="4" th:selected="*{rankId==4}">未定级</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">显示顺序：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="displayOrder" id="displayOrder" th:field="*{displayOrder}" required>
                    </div>
                </div>
            </form>
        </div>
        <th:block th:include="include :: footer" />
    </body>
</html>
